﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace HRM.CustomControl
{
    /// <summary>
    /// Interaction logic for PagingControl.xaml
    /// </summary>
    public partial class PagingControl : UserControl
    {
        public PagingControl()
        {
            InitializeComponent();
        }

        public ICommand FirstPageCommand
        {
            get { return (ICommand)GetValue(FirstPageCommandProperty); }
            set { SetValue(FirstPageCommandProperty, value); }
        }

        public static readonly DependencyProperty FirstPageCommandProperty =
            DependencyProperty.Register("FirstPageCommand", typeof(ICommand), typeof(PagingControl));

        public ICommand NextPageCommand
        {
            get { return (ICommand)GetValue(NextPageCommandProperty); }
            set { SetValue(NextPageCommandProperty, value); }
        }

        public static readonly DependencyProperty NextPageCommandProperty =
            DependencyProperty.Register("NextPageCommand", typeof(ICommand), typeof(PagingControl));

        public ICommand LastPageCommand
        {
            get { return (ICommand)GetValue(LastPageCommandProperty); }
            set { SetValue(LastPageCommandProperty, value); }
        }

        public static readonly DependencyProperty LastPageCommandProperty =
            DependencyProperty.Register("LastPageCommand", typeof(ICommand), typeof(PagingControl));

        public ICommand PreviosPageCommand
        {
            get { return (ICommand)GetValue(PreviosPageCommandProperty); }
            set { SetValue(PreviosPageCommandProperty, value); }
        }

        public static readonly DependencyProperty PreviosPageCommandProperty =
            DependencyProperty.Register("PreviosPageCommand", typeof(ICommand), typeof(PagingControl));

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (FirstPageCommand != null) FirstPageCommand.Execute(null);
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            if (PreviosPageCommand != null) PreviosPageCommand.Execute(null);
        }

        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            if (NextPageCommand != null) NextPageCommand.Execute(null);
        }

        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            if (LastPageCommand != null) LastPageCommand.Execute(null);
        }

        public static readonly DependencyProperty PageIndexProperty =
            DependencyProperty.Register("PageIndex", typeof(int), typeof(PagingControl));

        public static readonly DependencyProperty NumberOfPagesProperty =
            DependencyProperty.Register("NumberOfPages", typeof(int), typeof(PagingControl));

        public static readonly DependencyProperty PageSizeProperty =
            DependencyProperty.Register("PageSize", typeof(int), typeof(PagingControl));

        public int PageIndex
        {
            get { return Convert.ToInt32(GetValue(PageIndexProperty)); }
            set { SetValue(PageIndexProperty, value); }
        }

        public int NumberOfPages
        {
            get { return Convert.ToInt32(GetValue(NumberOfPagesProperty)); }
            set { SetValue(NumberOfPagesProperty, value); }
        }

        public int PageSize
        {
            get { return Convert.ToInt32(GetValue(PageSizeProperty)); }
            set { SetValue(PageSizeProperty, value); }
        }

    }
}
